package com.xiaochong.tir.api.controller;

import com.xiaochong.tir.api.service.KLineTradesService;
import com.xiaochong.tir.api.util.ApiVersion;
import com.xiaochong.tir.common.data.redisPo.KActionTotalPo;
import com.xiaochong.tir.common.data.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by org on 2018/6/27.
 */
@Api(value="选币、行情k线1.2接口")
@RestController
@RequestMapping(ApiVersion.API_V1_PREFIX+"/Kline")
public class KLineTradesController {

    @Autowired
    private KLineTradesService kLineTradesService;

    @ApiOperation(value = "成交大单监控", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "number", value = "查询数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "exchangeId", value = "交易所id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "symbol", value = "交易对", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/historyTradesMax")
    public ApiResultVo<List<ApiMaxTradesVo>> historyTradesMax(@RequestParam(value = "number") Integer number, @RequestParam(value = "exchangeId") Integer exchangeId, @RequestParam(value = "symbol") String symbol){
        return kLineTradesService.historyTradesMax(number,exchangeId,symbol);
    }
    @ApiOperation(value = "资金流入今日、5、10、一小时、24小时情况", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "exchangeId", value = "交易所id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "symbol", value = "交易对", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "timePart", value = "3h/1d", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/capitalInflowSituation")
    public ApiResultVo<ApiCapitalInflowSituationDataVo> capitalInflowSituation(@RequestParam(value = "exchangeId") Integer exchangeId, @RequestParam(value = "symbol") String symbol, @RequestParam(value = "timePart") String timePart){
        return kLineTradesService.capitalInflowSituation(exchangeId,symbol,timePart);
    }
    @ApiOperation(value = "自定义栏目", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @GetMapping("/kActionQuantizationAllTitle")
    public ApiResultVo<List<ApiKLineTitleVo>> kActionQuantizationAllTitle(){
        return kLineTradesService.kActionQuantizationAllTitle();
    }
    @ApiOperation(value = "行情k线-搜索交易对", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "searchName", value = "searchName", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "userToken", value = "用户token", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/kActionQuantizationSearch")
    public ApiResultVo<List<ApiKActionQuantizationVo>> kActionQuantizationSearch(@RequestParam(value = "searchName") String searchName,
                                                                                 @RequestParam(value = "userToken",required = false) String userToken){
        return kLineTradesService.kActionQuantizationSearch(searchName,userToken);
    }
    @ApiOperation(value = "行情k线-市场行情", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @PostMapping("/kActionQuantizationSearchMarket")
    public ApiResultVo<List<ApiKActionQuantizationVo>> kActionQuantizationSearchMarket(@RequestBody kActionQuantizationParamsVo kActionQuantizationParamsVo){
        return kLineTradesService.kActionQuantizationSearchMarket(kActionQuantizationParamsVo);
    }
    @ApiOperation(value = "行情k线", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @PostMapping("/kActionQuantization")
    public ApiResultVo<List<ApiKActionQuantizationVo>> kActionQuantization(@RequestBody kActionQuantizationParamsVo kActionQuantizationParamsVo){
        return kLineTradesService.kActionQuantization(kActionQuantizationParamsVo);
    }
    @ApiOperation(value = "选币", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "index", value = "查询类型，1:30天创新高数据2:连续上涨突破3:均线上涨4:上涨突破箱体5:30天创新低数据6:连续下跌破位7:跌破箱体8:均线下跌", required = true, dataType = "int", paramType = "query"),
    })
    @GetMapping("/SelectCoinQuantization")
    public ApiResultVo<List<CurrencyQuotationResultVo>> SelectCoinQuantization(@RequestParam(value = "index") Integer index){
        return kLineTradesService.SelectCoinQuantization(index);
    }
    @ApiOperation(value = "选币-分页", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @PostMapping("/SelectCoinQuantizationPage")
    public ApiResultVo<List<CurrencyQuotationResultVo>> SelectCoinQuantizationPage(@RequestBody SelectCoinQuantizationParamsVo selectCoinQuantizationParamsVo){
        return kLineTradesService.SelectCoinQuantizationPage(selectCoinQuantizationParamsVo);
    }
    @ApiOperation(value = "k线行情-查询交易对是否自选", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误,返回参数selfSelectFlag，1是组选，2不是自选")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "middleId", value = "中间件id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "userToken", value = "用户token", required = false, dataType = "String", paramType = "query")
    })
    @GetMapping("/validateSymbolSelfSelect")
    public ApiResultVo validateSymbolSelfSelect(@RequestParam(value = "middleId") Integer middleId,
                                                                                 @RequestParam(value = "userToken",required = false) String userToken){
        return kLineTradesService.validateSymbolSelfSelect(middleId,userToken);
    }
    /* @ApiOperation(value = "资金流入3h数据", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "exchangeId", value = "交易所id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "symbol", value = "交易对", required = true, dataType = "String", paramType = "query")
    })
   @GetMapping("/capitalInflowSituationOfThreeHours")
    public ApiResultVo<List<ApiCapitalInflowSituationVo>> capitalInflowSituationOfThreeHours(@RequestParam(value = "exchangeId") Integer exchangeId,@RequestParam(value = "symbol") String symbol){
        return kLineTradesService.capitalInflowSituationOfThreeHours(exchangeId,symbol);
    }
    @ApiOperation(value = "今日资金流入", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "exchangeId", value = "交易所id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "symbol", value = "交易对", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/capitalInflowSituationTodayTotal")
    public ApiResultVo<List<ApiCapitalInflowSituationVo>> capitalInflowSituationTodayTotal(@RequestParam(value = "exchangeId") Integer exchangeId,@RequestParam(value = "symbol") String symbol){
        return kLineTradesService.capitalInflowSituationTodayTotal(exchangeId,symbol);
    }*/
}
